/**
 * Copyright (c) 2009 Teoti Graphix, LLC See:
 *     http://tkarchitecture.teotigraphix.org
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 * 
 * @author Michael Schmalle mschmalle@teotigraphix.com
 */
package org.teotigraphix.dx.event
{

import flash.events.Event;
import flash.events.IEventDispatcher;

import org.teotigraphix.dx.interfaces.IComponentBehavior;

/**
 * An event for a <code>behaviorLayer</code> in an 
 * <code>IBehaviorLayerAware</code> component.
 * 
 * @author Michael Schmalle
 * @copyright Teoti Graphix, LLC
 * @date 01-20-09
 */
public class BehaviorLayerEvent 
	   extends ComponentLayerEvent
{
	include "../core/Version.as"

	//--------------------------------------------------------------------------
	//
	//  Public Class :: Properties
	//
	//--------------------------------------------------------------------------
	
	/**
	 * Dispatched when a behavior is added to the <code>IBehaviorLayer</code>.
	 * 
	 * @eventType behaviorAdd
	 */
	public static const BEHAVIOR_ADD:String  = "behaviorAdd";
	
	/**
	 * Dispatched when a behavior is removed from the <code>IBehaviorLayer</code>.
	 * 
	 * @eventType behaviorRemove
	 */
	public static const BEHAVIOR_REMOVE:String  = "behaviorRemove";
	
	//--------------------------------------------------------------------------
	//
	//  Public :: Properties
	//
	//--------------------------------------------------------------------------
	
	//----------------------------------
	//  behavior
	//----------------------------------
	
	/**
	 * The <code>IComponentBehavior</code> instance being added/removed.
	 */
	public var behavior:IComponentBehavior;
	
	//--------------------------------------------------------------------------
	//
	//  Constructor
	//
	//--------------------------------------------------------------------------

	/**
	 * Create a new <code>BehaviorLayerEvent</code> instance.
	 * 
	 * @param type A string indicating the event type for the current event.
	 * @param api The behavior api being added/removed.
	 * @param behavior The <code>behavior</code> instance.
	 * @param component The <code>IEventDispatcher</code> that owns the 
	 * <code>behaviorLayer</code>.
	 */
	public function BehaviorLayerEvent(
		type:String, 
		api:Class = null, 
		behavior:IComponentBehavior = null, 
		component:IEventDispatcher = null)
	{
		super(type, null, null, component, false, true);
		this.api = api;
		this.behavior = behavior;
	}
	
	//--------------------------------------------------------------------------
	//
	//  Overriden Public :: Methods
	//
	//--------------------------------------------------------------------------

	/**
	 * Creates a clone instance using the current property state of this 
	 * instance.
	 */
	override public function clone():Event
	{
		return new BehaviorLayerEvent(type, api, behavior, component);
	}	
}
}